<?php
/**
 * Created by PhpStorm.
 * User: 64423
 * Date: 2018/10/16
 * Time: 15:17
 */

namespace app\shop\model;


use think\Model;

class ArticleCategoryModel extends Model
{
    protected $table = 'dp_article_category';
    protected $pk = 'id';
    protected $field = true;

    public static function getAllList()
    {
        return self::paginate(10);
    }

    public static function getOne($id)
    {
        return self::where('id', $id)->find();
    }

    public static function store($data, $id=0)
    {
        if($id == 0){
            return self::insert($data);
        }else{
            return self::where('id', $id)->update($data);
        }
    }

    public static function del($id)
    {
        return self::where('id', $id)->delete();
    }

    public static function nameExist($name, $id=0)
    {
        if($id == 0){
            return self::where('name',$name)->find();
        }else{
            return self::where('name', $name)->where('id','<>', $id)->find();
        }
    }
}